package com.bwie.controller;

import com.bwie.domain.TbRepair;
import com.bwie.service.RepairService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2024/11/5 8:59
 */

@RestController
@RequestMapping("/order/repair")
@Slf4j
public class RepairController {

    @Autowired
    RepairService repairService;

    /**
     * 近两周每天的报修数量
     * @return
     */
    @PostMapping(value = "/getRepairCountByWeek")
    public R getRepairCountByWeek() {
        return repairService.getRepairCountByWeek();
    }

    /**
     * 计，以柱形图白的形式展示近一年中每月
     * 的维修状态占比
     * @return
     */
    @PostMapping(value = "/getRepairStatusByMonth")
    public R getRepairStatusByMonth() {
        return repairService.getRepairStatusByMonth();
    }

    /**
     * 对报修记录表的报修区域、报修设备进行统计，以柱形图的形式展示每个区域中的每种设备的维修状态占比
     * @return
     */
    @PostMapping(value = "/getRepairStatusByArea")
    public R getRepairStatusByArea() {
        return repairService.getRepairStatusByArea();
    }

    /**
     * 分页查询报修单
     * @param pageInfoVo
     * @return
     */
    @PostMapping(value = "/getRepairList")
    public R getRepairList(@RequestBody PageInfoVo pageInfoVo) {
        return repairService.getRepairList(pageInfoVo);
    }

    /**
     * 获取报修类型
     * @return
     */
    @PostMapping(value = "/getTypeList")
    public R getTypeList() {
        return repairService.getTypeList();
    }

    /**
     * 图片上传接口
     * @return
     */
    @PostMapping(value = "/uploadFile")
    public R uploadFile(@RequestPart("file") MultipartFile file) {
        return repairService.uploadFile(file);
    }

    /**
     * 添加报修单
     * @param tbRepair
     * @return
     */
    @PostMapping(value = "/addRepair")
    public R addRepair(@RequestBody TbRepair tbRepair) {
        return repairService.addRepair(tbRepair);
    }

    /**
     * 获取报修区域
     * @return
     */
    @PostMapping(value = "/getAreaList")
    public R getAreaList() {
        return repairService.getAreaList();
    }

}
